/**
 * @param {number[]} nums
 * @return {boolean}
 */
var canJump = function (nums) {
  let l = nums[0],
    n = nums.length;
  for (let i = 0; i <= l; i++) {
    if (nums[i] + i > l) {
      l = nums[i] + i;
    }
    if (l >= n-1) {
      return true;
    }
  }
  return false;
};

console.log(canJump([1,2,3]))